<?php

namespace App\Http\Model;

class Order extends Base {

    protected $hidden = [
        'updated_at'
    ];

    protected $fillable = ['user_id', 'sn', 'status', 'foreign_id', 'type', 'goods_id', 'goods_number', 'address'];

    public function goods()
    {
        return $this->belongsTo('App\Http\Model\Goods');
    }

    public function getAddressAttribute($value)
    {
        if ($value == null) return $value;

        return json_decode($value);
    }

    public function getCreatedAtAttribute($date)
    {
        return \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->timestamp;
    }
}



